package longrise.phone.com.bjjt_jyb.myaccident;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.GridView;
import android.widget.TextView;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.FormParameter;
import com.longrise.android.LFView;
;import longrise.phone.com.bjjt_jyb.Adapter.AccidentPicAdapter;
import longrise.phone.com.bjjt_jyb.R;

/**
 * 定责、定损照片界面
 */
public class AccidentPicView extends LFView {

    private Context mContext;

    private View mView;

    private EntityBean[] baseBean;

    private GridView mGridView;

    private int type;//照片类型(0表示定责;1表示定损)

    public AccidentPicView(Context context, EntityBean[] bean) {
        super(context);
        this.mContext = context;
        this.baseBean = bean;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter form = new FormParameter();
        form.setShowtitle(false);
        return form;
    }

    @Override
    public View getView() {
        return mView;
    }

    @Override
    public void init() {
        if (null == mContext) {
            return;
        }
        mView = LayoutInflater.from(mContext).inflate(R.layout.view_accidentpics, null);
        if (mView == null) {
            return;
        }
        //标题栏
        TextView titleTV = (TextView) mView.findViewById(R.id.tv_title);
        if (type == 0) {
            titleTV.setText(R.string.response_pictures);
        } else {
            titleTV.setText(R.string.loss_pictures);
        }
        mView.findViewById(R.id.hn_btn_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                closeForm();
                OnDestroy();
            }
        });

        mGridView = (GridView) mView.findViewById(R.id.apic_gridview);
        mGridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
        AccidentPicAdapter mAdapter = new AccidentPicAdapter(mContext);
        //获取数据
        mAdapter.setLists(baseBean);
        mGridView.setAdapter(mAdapter);
    }

    @Override
    public void refresh() {

    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public void OnDestroy() {
        super.OnDestroy();
        mView = null;
        if (null != mGridView) {
            mGridView.setAdapter(null);
        }
        mGridView = null;
        baseBean = null;
    }
}
